//	S3 AM
//
#ifndef ShowFindUpdateAM_H_
#define ShowFindUpdateAM_H_

#include <string>
#include <algorithm>


using namespace std;

class ShowFindUpdateAM
{
public:
	
	static Product prod;
	static double prod_price;
	static vector<Cart_item>items;
	static vector<Product>prods;
	static vector<Category>cats;
	static vector<Cart>carts;
	static vector<Customer>custs;
	static vector<double>price;
	static vector<Product>b;
	static vector<Cart>cust_carts;
	static vector<Cart_item>cust_items;

	//ShowUpdateFindAM(){} 
	ShowFindUpdateAM(){}	//RY
	
	static void printCart(int pCart_id, vector<Cart_item> pCart_items)
	{
		cout << "cart_id: " << pCart_id << endl;
		int iCartItems;
		for (iCartItems=0;iCartItems<pCart_items.size();iCartItems++)
		{
			if (pCart_items.at(iCartItems).getcartid() == pCart_id) {
				cout << " " << pCart_items.at(iCartItems).display() << endl;
			}
		}
	}

	static void show(vector<Product> prods)
	{
		/*sort(price.begin(),price.end());
			
		for (int i=0; i<price.size() ; ++i)
		{
			for (int j=0; j<price.size() ; ++j)
			{
				if (prods[i].prod_price == price[j])
				{
					b[j] = prods[i];
				}
			}
		}*/
		
		for (int i=0 ; i<prods.size() ; ++i)//repeats for each line //RY I changed b to prods for now
		{
			cout 	<< prods[i].prod_name << " "
					<< '(' << prods[i].prod_id << "): "
					<< prods[i].prod_price<< endl;
		}	
		cout << endl;
	}
	
	static void update_add_cart_item(vector<Cart_item> pCart_items) //RY added static
	{
		int tcart_id, tprod_id, tprod_qty;
		//int year=0,day=0,month=0;
		cout << "Enter the cart_id: \n> ";
		cin >> tcart_id;
		printCart(tcart_id, pCart_items);
		//cout << "Enter the cust_id \n> ";
		//cin >> tcust_id;
		/*cout<<"Enter Date please? \n>";
		cin >> year
			>> day
			>> month;*/
		cout << "Enter the prod_id: \n> ";
		cin >> tprod_id;
		cout << "Enter the prod_qty: \n> ";
		cin >> tprod_qty;
		//int tcart_item_id = pCart_items.size();
		pCart_items.push_back(Cart_item(pCart_items.size(),tcart_id,tprod_id,tprod_qty));
		printCart(tcart_id, pCart_items);
	}	
};

#endif //ShowFindUpdateAM_H_